<?php
namespace common\models;

use Yii;

/**
 * This is the model class for table "goods".
 *
 * @property integer $id
 * @property string $name
 * @property string $price
 * @property integer $num
 * @property integer $sum
 * @property integer $look
 * @property string $logo
 * @property double $sumlen
 * @property double $bladelen
 * @property double $stemlen
 * @property double $width
 * @property double $height
 * @property double $hard
 * @property string $stuff
 * @property integer $slot
 * @property string $sheath
 * @property string $grind
 * @property string $craftwork
 * @property double $weight
 * @property string $gift
 * @property string $message
 * @property integer $pid
 */
class Goods extends \yii\db\ActiveRecord
{

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'goods';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [
                [
                    'name',
                    'price',
                    'num',
                    'sumlen',
                    'bladelen',
                    'stemlen',
                    'width',
                    'height',
                    'hard',
                    'stuff',
                    'sheath',
                    'grind',
                    'craftwork',
                    'weight',
                    'gift',
                    'message',
                    'hot',
                    'tag',
                    'pid',
                ],
                'required'
            ],
            ['logo','required','on'=>'create'],
            [
                [
                    'price',
                    'sumlen',
                    'bladelen',
                    'stemlen',
                    'width',
                    'height',
                    'hard',
                    'weight'
                ],
                'number'
            ],
            [
                [
                    'num',
                    'pid',
                    'hot',
                    'tag'
                ],
                'integer'
            ],
            [
                [
                    'message'
                ],
                'string'
            ],
            [
                [
                    'name',
                    'gift'
                ],
                'string',
                'max' => 25
            ],
            [
                [
                    'logo'
                ],
                'file',
                'extensions' => 'jpg,gif,png',
            ],
            [
                [
                    'stuff',
                    'sheath',
                    'grind'
                ],
                'string',
                'max' => 8
            ],
            [
                [
                    'craftwork'
                ],
                'string',
                'max' => 25
            ]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => '名称',
            'price' => '价格',
            'num' => '数量',
            'sum' => '销量',
            'look' => '浏览量',
            'logo' => '主图',
            'sumlen' => '总长',
            'bladelen' => '刃长',
            'stemlen' => '柄长',
            'width' => '刃宽',
            'height' => '刃厚',
            'hard' => '硬度',
            'stuff' => '刃材',
            'sheath' => '鞘材',
            'grind' => '装具',
            'craftwork' => '工艺',
            'weight' => '重量',
            'gift' => '赠品',
            'message' => '内容',
            'pid' => '上级栏目',
            'hot'=>'推荐',
            'tag'=>'标签'
        ];
    }
}
